package com.lucene.text;

import java.io.IOException;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.lucene.dao.GoodClassifyDao;
import com.lucene.dao.LuceneDao;
import com.lucene.model.GoodDetails;

@RunWith(SpringJUnit4ClassRunner.class) // 使用Springtest测试框架
@ContextConfiguration("/applicationContext.xml") // 加载配置

public class GoodIndexAdd {
	   private LuceneDao luceneDao=new LuceneDao();
	    @Autowired
	    private GoodClassifyDao goodClassifyDao;
	    @Test
	    public void addIndexForAll() throws IOException {
	        /**
	         * 8-62：商品种类ID的起始Commodity_classification
	         * 根据商品种类ID查询所属类别的商品信息，建立你的商品种类和商品索引，原因我只伪造了两个商品种类假数据，就是id=15和16的商品，所以我们只建立对他的索引咯
	         * */
	        for(int i = 15; i <= 16; i++){
	            System.out.println("goodClassifyDao     "+goodClassifyDao);
	            List<GoodDetails> list = goodClassifyDao.findGoodDetailsByClassifyID(i);
	            System.out.println("junitTest:list.size()="+list.size());
	            if(list.size()>0){
	            	luceneDao.addIndex(list);
	            }
	        }
	    }
}
